<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>游戏列表</title>
    
    <meta charset="utf-8"/>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" href="gold/css/bootstrap.min.css">
	<link rel="stylesheet" href="gold/css/index.css" />
	<script src="gold/js/jquery.js"></script>
	<script src="gold/js/bootstrap.min.js"></script>
	<style type="text/css">
		#container {
			margin-top: -20px;
			margin-left: 10px;
		}
		td {
			vertical-align: middle !important;
		}
	</style>
	<script type="text/javascript">
		$(function(){
			$("#all").click(function(){
				var all = $("#all").prop("checked");
				if(all){
					$("input[name='opt']").prop("checked",true);
				}else{
					$("input[name='opt']").prop("checked",false);
				}
			});
		});
		function deleteGame(){
			var v1 = confirm("确认删除吗？");
			if(v1){
				var arr = [];
				$("input[name='opt']").each(function(){
					var choose = $(this).prop("checked");
					if(choose){
						arr.push($(this).val());
					}
				});
				if(arr.length<=0){
					alert("请选择至少一行删除！");
					return;
				}
				location.href="deleteGame.do?gameIdStringArr="+arr;
			}
		}
	</script>

  </head>
  
  <body>
    <div id="container">
		<div class="page-header">
			<h2>游戏列表</h2>
		</div>
		<form action="getGameByLike.do" method="post">
			<div class="row">
				<div class="col-xs-6 col-sm-3">
					<div class="row">
						<div class="col-xs-8 col-sm-3">
							<span class="btn btn-default">游戏名称</span>
						</div>
						<div class="col-xs-3 col-sm-8">
							<input type="text" 
								class="form-control" name="gameName"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6 col-sm-2">
					<div class="row">
						<div class="col-xs-8 col-sm-4">
							<span class="btn btn-default">游戏类型</span>
						</div>
						<div class="col-xs-3 col-sm-8">
							<select  class="form-control" name="gameTypeId">
								<c:forEach items="${gameTypeList}" var="gameType">
									<option value="${gameType.typeId}">${gameType.typeName}</option>
								</c:forEach>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6 col-sm-4">
					<input type="submit" class="btn btn-primary" id="search" value="查询" />
				</div>
			</div>
		</form>
		<div class="row">&nbsp;</div>
		
		<div class="row">
			<div class="col-xs-6 col-sm-4">
				<a class="btn btn-primary" data-toggle="modal"
					data-target="#myModal"> <span class="glyphicon glyphicon-plus"></span>
					新增</a>
				<a class="btn btn-danger" onclick="deleteGame()"> <span
					class="glyphicon glyphicon-trash" ></span> 删除</a>
			</div>
		</div>

		<div class="modal fade" id="myModal" tabindex="-1" >
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							>&times;</button>
						<h4 class="modal-title" id="myModalLabel">添加游戏</h4>
					</div>
					<div class="modal-body">
						<form action="insertGame.do" method="post" enctype="multipart/form-data" class="form-horizontal">
							<div class="form-group">
								<label for="gameName" class="col-sm-2 control-label">游戏名称</label>
								<div class="col-sm-10">
										<input type="text" name="gameName" placeholder="请输入游戏名称" class="form-control"/>
								</div>
							</div>
							<div class="form-group">
								<label for="gameStatusId" class="col-sm-2 control-label">游戏状态</label>
								<div class="col-sm-10">
									<c:forEach items="${gameStatusList}" var="gameStatus">
										<input type="radio" name="gameStatusId" value="${gameStatus.id}" checked="checked"/>&nbsp;${gameStatus.status}
									</c:forEach>	
								</div>
							</div>
							<div class="form-group">
								<label for="gameTypeId" class="col-sm-2 control-label">游戏类型</label>
								<div class="col-sm-10">
										<select class="form-control" name="gameTypeId">
											<c:forEach items="${gameTypeList}" var="gameType">
												<option value="${gameType.typeId}">${gameType.typeName}</option>
											</c:forEach>
										</select>
								</div>
							</div>
							<div class="form-group">
								<label for="gameDevelopers" class="col-sm-2 control-label">开发商</label>
								<div class="col-sm-10">
										<input type="text" name="gameDevelopers" placeholder="例（腾讯开发商）" class="form-control"/>
								</div>
							</div>
							<div class="form-group">
								<label for="gameIntroduction" class="col-sm-2 control-label">游戏简介</label>
								<div class="col-sm-10">
										<textarea rows="3" cols="20" class="form-control" name="gameIntroduction"></textarea>
								</div>
							</div>
							<div class="form-group">
								<label for="gameDetail" class="col-sm-2 control-label">游戏详情</label>
								<div class="col-sm-10">
										<textarea rows="3" cols="20" class="form-control" name="gameDetail"></textarea>
								</div>
							</div>
							<div class="form-group">
								<label for="gameFiling" class="col-sm-2 control-label">备案号</label>
								<div class="col-sm-10">
										<input type="text" name="gameFiling" placeholder="例（1234567890）" class="form-control"/>
								</div>
							</div>
							<div class="form-group">
								<label for="gameCover" class="col-sm-2 control-label">封面图片</label>
								<div class="col-sm-10">
										<input type="file" name="gameCoverFile" />
								</div>
							</div>
							<div class="form-group">
								<label for="gameScreen" class="col-sm-2 control-label">内容图片</label>
								<div class="col-sm-10">
										<input type="file" name="gameScreen1" />
										<input type="file" name="gameScreen2" />
										<input type="file" name="gameScreen3" />
								</div>
							</div>
							<div class="form-group">
								<label for="gameTariffeString" class="col-sm-2 control-label">话费价格</label>
								<div class="col-sm-10">
										<input type="text" name="gameTariffeString" class="form-control"/>
								</div>
							</div>
							<div class="form-group">
								<label for="gameCurrencyString" class="col-sm-2 control-label">游币价格</label>
								<div class="col-sm-10">
										<input type="text" name="gameCurrencyString" class="form-control"/>
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-10 col-sm-offset-2">
										<input type="submit" class="btn btn-default" value="添加游戏"/>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

		<div class="row">&nbsp;</div>
		
		<div class="row">
			<div class="col-xs-6 col-sm-11">
				<div class="table-responsive"
					style="vertical-align: middle;text-align: center;">
					<table id="searchTable"
						class="table table-bordered table-hover table-condensed  ">
						<tr>
							<td><input type="checkbox" id="all" value="全选"
								 /> 全选</td>
							<td>ID</td>
							<td>游戏名称</td>
							<td>游戏类别</td>
							<td>游戏封面</td>
							<td>状态</td>
							<td>游币价格</td>
							<td>话费价格</td>
							<td>创建时间</td>
							<td>更新时间</td>
							<td>操作</td>
						</tr>
						<c:forEach items="${gameList}" var="game">
							<tr>
								<td><input type='checkbox' 
									name='opt' value='${game.gameId}' />
								</td>
								<td>${game.gameId}</td>
								<td>${game.gameName}</td>
								<td>${game.gameType}</td>
								<td>
									<div class="col-xs-6  col-md-offset-4">
										<img class="" width="33" height="30"
											src="/file/game/${game.gameCover}" />
									</div></td>
								<td>${game.gameStatus} </td>
								<td>${game.gameCurrency}</td>
								<td>${game.gameTariffe}</td>
								<td>
									${game.gameCreateTime}
								</td>
								<td>
									${game.gameUpdateTime}
								</td>
								<td>
									<div class="col-xs-6 col-sm-2 col-md-offset-2">
										<a class="btn btn-info btn-sm"
											href="toUpdateGameJsp.do?gameId=${game.gameId}">
											<span class="glyphicon glyphicon-pencil"></span>修改</a>
									</div>
									<div class="col-xs-6 col-sm-4 col-md-offset-2">
										<a class="btn btn-warning btn-sm"
											href="getGameDetails.do?gameId=${game.gameId}">
											<span class="glyphicon glyphicon-pencil"></span>详情</a>
									</div></td>
							</tr>
						</c:forEach>
							
					</table>
				</div>
			</div>
		</div>
		<div class="row">
			&nbsp;
			<a class="btn btn-primary" href="getAllGameByPage.do?nowPageString=${nowPage-1}">上一页</a>
			<a class="btn btn-primary" href="getAllGameByPage.do?nowPageString=${nowPage+1}">下一页</a>
		</div>
	</div>
	<c:if test="${msg!=null}">
  		<script type="text/javascript">
  			alert("${msg}");
  		</script>
  	</c:if>
  </body>
  	
</html>
